package com.lg.partition43;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/4/11 10:55
 */
public class P4281AHOI2008_紧急集合 {

    private static final int N = 500010, M = 2 * N, D = (int) (Math.log(N) / Math.log(2));
    private static int[] h = new int[N], e = new int[M], ne = new int[M], depth = new int[N];
    private static int[] q = new int[N], dist = new int[N];
    private static int[][] f = new int[N][D + 1];
    private static int n, m, idx = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        n = Integer.parseInt(ss[0]);
        m = Integer.parseInt(ss[1]);
        for (int i = 1; i <= n; i++) h[i] = -1;
        for (int i = 0; i < n - 1; i++) {
            ss = reader.readLine().split(" ");
            int a = Integer.parseInt(ss[0]), b = Integer.parseInt(ss[1]);
            add(a, b);
            add(b, a);
        }
        bfs(1);
        for (int i = 0; i < m; i++) {
            ss = reader.readLine().split(" ");
            int a = Integer.parseInt(ss[0]), b = Integer.parseInt(ss[1]), c = Integer.parseInt(ss[2]);
            int anc1 = lca(a, b), anc2 = lca(b, c), anc3 = lca(a, c);
            int d = dist[a] + dist[b] + dist[c] - dist[anc1] - dist[anc2] - dist[anc3];
            int t = -1;
            if (anc1 == anc2) t = anc3;
            else if (anc2 == anc3) t = anc1;
            else if (anc1 == anc3) t = anc2;
            writer.write(String.format("%d %d\n", t, d));
        }
        writer.flush();
    }

    private static int lca(int x, int y) {
        if (depth[x] < depth[y]) {
            int t = x;
            x = y;
            y = t;
        }
        for (int i = D; i >= 0; i--) {
            if (depth[f[x][i]] >= depth[y]) {
                x = f[x][i];
            }
        }
        if (x == y) return x;
        for (int i = D; i >= 0; i--) {
            if (f[x][i] != 0 && f[x][i] != f[y][i]) {
                x = f[x][i];
                y = f[y][i];
            }
        }
        return f[x][0];
    }

    private static void bfs(int root) {
        int hh = 0, tt = 0;
        q[0] = root;
        depth[root] = 1;
        while (hh <= tt) {
            int u = q[hh++];
            for (int i = h[u]; i != -1; i = ne[i]) {
                int v = e[i];
                if (depth[v] != 0) continue;
                depth[v] = depth[u] + 1;
                dist[v] = dist[u] + 1;
                f[v][0] = u;
                for (int j = 1; j <= D; j++) {
                    int anc = f[v][j - 1];
                    f[v][j] = f[anc][j - 1];
                }
                q[++tt] = v;
            }
        }
    }

    private static void add(int a, int b) {
        e[idx] = b;
        ne[idx] = h[a];
        h[a] = idx++;
    }
}
